package com.vids.utils;

public  class VIIDUtils {


    public static String getParentOrgID(String orgID) {
        // 分析平台编号,确定是属于那一级的平台
        if (isProvince(orgID)) {
            // 省级
            return "";
        }
        if (isCity(orgID)) {
            // 市级
            return orgID.substring(0, 2) + "0000";
        }
        if (isCounty(orgID)) {
            // 县级
            return orgID.substring(0, 4) + "00";
        }
        return "";
    }

    public static boolean isCounty(String orgID) {
        return !orgID.substring(4).equals("00");
    }

    public static boolean isCity(String orgID) {
        return orgID.substring(4).equals("00")
                && !orgID.substring(2, 4).equals("00");
    }

    public static boolean isProvince(String orgID) {
        return orgID.substring(2).equals("0000");
    }


    public static boolean isChildResource(String resourceOrgID, String orgID) {
        if (isProvince(orgID)) {
            if (resourceOrgID.substring(0, 2).equals(orgID.substring(0, 2))) {
                return true;
            }
        } else if (isCity(orgID)) {
            if (resourceOrgID.substring(0, 4).equals(orgID.substring(0, 4))) {
                return true;
            }
        } else {
            return false;
        }
        return false;
    }



   public static boolean isDeviceId(String deviceId){
        if(deviceId.length()==20){
            return true;
        }
        return false;
   }

    public static boolean isBaseObjId(String baseObjId){
        if(baseObjId.length()==41){
            return true;
        }
        return false;
    }
    public static boolean isSemanticsTypeId(String semanticsTypeId){
        if(semanticsTypeId.length()==48){
            return true;
        }
        return false;
    }

    public static boolean isCaseId(String caseId){
        if(caseId.length()==30){
            return true;
        }
        return false;
    }
    public static boolean isLaneId(String laneId){
        if(laneId.length()<=2){
            return true;
        }
        return false;
    }


    public static boolean isPerson(String deviceID){
        return deviceID.substring(41,43).equals("01");
    }

    public static boolean isVehicle(String deviceID){
        return deviceID.substring(41,43).equals("02");
    }

    public static boolean isNonVehicle(String deviceID){
        return deviceID.substring(41,43).equals("03");
    }

    public static boolean isThing(String deviceID){
        return deviceID.substring(41,43).equals("04");
    }
    public static boolean isFace(String deviceID){
        return deviceID.substring(41,43).equals("06");
    }
   public static boolean isFile(String deviceID){
        return deviceID.substring(20,22).equals("03");
    }


    public static boolean isVIID(String deviceID){
        return deviceID.substring(10,13).equals("503");
    }
    public static boolean isAnalysissystem(String deviceID){
        return deviceID.substring(10,13).equals("502");
    }
    public static boolean isAppPlatform(String deviceID){
        return deviceID.substring(10,13).equals("504");
    }

    public static boolean isApe(String deviceID){
        return deviceID.substring(10,13).equals("119");
    }
    public static boolean isAps(String deviceID){
        return deviceID.substring(10,13).equals("120");
    }
    public static boolean isTollgate(String deviceID){
        return deviceID.substring(10,13).equals("121");
    }


}
